package com.lujieni.springbootflowable;

import org.flowable.engine.*;
import org.flowable.engine.repository.Deployment;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.HashMap;
import java.util.Map;

/**
 * 排他网关
 */
@SpringBootTest
class SpringbootFlowableApplicationTests5 {

    @Autowired
    private ProcessEngine processEngine;
    @Autowired
    private RuntimeService runtimeService;


    @Test
    void deploy() {
        RepositoryService repositoryService = processEngine.getRepositoryService();
        Deployment deployment = repositoryService.createDeployment()
                .addClasspathResource("process/holiday2.bpmn20.xml")
                .name("排他网关")
                .deploy();
        System.out.println(deployment.getId());
    }

    /**
     * 请假大于3天 走总监审批
     * 请假小于等于3天 组长审批
     */
    @Test
    void startProcess() {
        Map<String, Object> map = new HashMap<>();
        map.put("num", 2);
        runtimeService.startProcessInstanceById("holiday2:1:97802ec5-8b2b-11f0-bac2-5847ca7eb09c", map);
    }

    @Test
    public void completeTask(){
        TaskService taskService = processEngine.getTaskService();
        taskService.complete("18da8021-8b2c-11f0-8412-5847ca7eb09c");
    }

}
